package com.quick.develop.flowable.service.process;

import cn.hutool.core.collection.CollUtil;
import com.quick.develop.flowable.domain.rule.BpmProcessRule;

import java.util.List;

/**
 * @author junyuan.liu
 * @description: 
 * @date 2022/5/18 13:42
 */
public interface IBpmProcessRuleService {

    /**
     * @description 通过定义ID获取规则
     * @param processDefinitionId 流程定义ID
     * @return java.util.List<com.quick.develop.flowable.domain.rule.BpmProcessRule>
     * @author junyuan.liu
     * @date 2022/5/18 16:47
     */
    List<BpmProcessRule> getRulesByProcessDefinitionId(String processDefinitionId);

    /**
     * @description 通过模型ID获取规则
     * @param modelId 模型ID 用于流程未发布
     * @return java.util.List<com.quick.develop.flowable.domain.rule.BpmProcessRule>
     * @author junyuan.liu
     * @date 2022/5/18 16:48
     */
    List<BpmProcessRule> getRulesByModelId(String modelId);
    
    /** 
     * @description 通过模型KEY获取规则
     * @param modelKey 模型KEY
     * @return java.util.List<com.quick.develop.flowable.domain.rule.BpmProcessRule>
     * @author junyuan.liu
     * @date 2023/7/3 11:06
     */ 
    List<BpmProcessRule> getRulesByModelKey(String modelKey);

    /**
     * @description  通过模型ID和节点编码获取规则
     * @param modelId 模型ID
     * @param nodeCode 节点
     * @return java.util.List<com.quick.develop.flowable.domain.rule.BpmProcessRule>
     * @author junyuan.liu
     * @date 2022/5/26 10:03
     */
    List<BpmProcessRule> getRules(String modelId, String nodeCode);

    /**
     * @description  通过模型key和编码获取规则
     * @param modelKey 模型key
     * @param nodeCode 节点
     * @return java.util.List<com.quick.develop.flowable.domain.rule.BpmProcessRule>
     * @author junyuan.liu
     * @date 2022/5/26 14:40
     */
    List<BpmProcessRule> getRulesByKeyNode(String modelKey, String nodeCode);

    default BpmProcessRule getRuleByKeyNode(String modelKey, String nodeCode){
        List<BpmProcessRule> list = getRulesByKeyNode(modelKey, nodeCode);
        if (CollUtil.isEmpty(list)) {
            return null;
        }
        return list.get(0);
    }

    /**
     * @description  创建规则
     * @param vo 请求体
     * @author junyuan.liu
     * @date 2022/5/24 14:32
     */
    void createProcessRule(BpmProcessRule vo);

    /**
     * @description  更新规则
     * @param vo 请求体
     * @author junyuan.liu
     * @date 2022/5/24 14:33
     */
    void updateProcessRule(BpmProcessRule vo);
    
    void saveProcessRule(BpmProcessRule vo);
    
    void saveProcessRuleList(List<BpmProcessRule> list);

    /**
     *
     * 根据流程key获取规则
     * @param modelKey
     * @return
     */
    List<BpmProcessRule> getRulesByModeKey(String modelKey);

    /**
     * 获取所有规则
     * @param modelKey
     * @return
     */
    List<BpmProcessRule> getRulesListByModeKey(String modelKey);

}
